

import 'package:ysy_flutter_mvvm_yuanxuan/api/HttpService.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/base/BaseModel.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/bean/base/BaseBean.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/bean/login/LoginDataBean.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/bean/login/RegisterDataBean.dart';

class LoginVM extends BaseModel{

  LoginBean? loginBean;
  EmptyJsonBean? registerBean;
  EmptyJsonBean? mSMSVerCode;

  //登录
  void getAppLogin({required String phone,required String password,bool isDialog=true,RequestDone? requestDone}){
    onNetWorkVerdictAndData(future: login(phone,password), result: (str){
      loginBean=BaseDataBean<LoginBean>.fromJson(str,(map) => LoginBean.fromJson(map)).data;
    },isDialog:isDialog,done: requestDone);
  }

  //登录-快捷登录
  void getLoginQuick({required String phone,required String code,bool isDialog=true,RequestDone? requestDone}){
    onNetWorkVerdictAndData(future: loginQuick(phone,code), result: (str){
      loginBean=BaseDataBean<LoginBean>.fromJson(str,(map) => LoginBean.fromJson(map)).data;
    },isDialog:isDialog,done: requestDone);
  }

  //注册
  void appRegister({required String phone,required String authCode,required String password,bool isDialog=true,RequestDone? requestDone}){
    onNetWorkVerdictAndData(future: register(phone,authCode,password), result: (str){
      registerBean=BaseDataBean<EmptyJsonBean>.fromJson(str,(map) => EmptyJsonBean.fromJson(map)).data;
    },isDialog:isDialog,done: requestDone);
  }

  //获取验证码  type  短信类型（1  login:登录,2  register:注册,3 update:修改密码，4 other:其他）
  void onSMSVerCode({required String phone,required int type,bool isDialog=true,RequestDone? requestDone}){
    onNetWorkVerdictAndData(future: smsVerCode(phone,type), result: (str){
      mSMSVerCode=BaseDataBean<EmptyJsonBean>.fromJson(str,(map) => EmptyJsonBean.fromJson(map)).data;
    },isDialog:isDialog,done: requestDone);
  }

}
